/**
 * DateUtil.java
 * 作者：iccboy
 * 2017年6月7日 创建文件
 */
package com.iccboy.cupload.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 **************************************************
 * 日期工具
 * 
 * @version 1.0.0
 * @author  iccboy
 **************************************************
 */
public class DateUtil {

	public static Date getTime(long longtime) {
		Calendar calendar = Calendar.getInstance();
		calendar.setTimeInMillis(longtime);
		return calendar.getTime();
	}

	public static String getTimeStr(long longtime, String pattern) {
		Date date = getTime(longtime);
		DateFormat formatter = new SimpleDateFormat(pattern);
		return formatter.format(date);
	}
	
	public static String getTimeStr(long longtime) {
		Date date = getTime(longtime);
		DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return formatter.format(date);
	}
}
